<template>
  <div class="app-container">
    <eHeader :query="query" />
    <!--表格渲染-->
    <el-table v-loading="loading" :data="data" size="small" style="width: 100%;">
      <el-table-column :show-overflow-tooltip="true" width="60" prop="name" label="服务商" />
      <el-table-column :show-overflow-tooltip="true" width="60" prop="reciveCount" label="派单数" />
      <el-table-column :show-overflow-tooltip="true" width="60" prop="finishCount" label="完成数" />
      <el-table-column :show-overflow-tooltip="true" width="60" prop="refuseCount" label="拒接数" />
      <el-table-column :show-overflow-tooltip="true" width="60" prop="returnCount" label="退回数" />
      <el-table-column :show-overflow-tooltip="true" width="70" prop="timeOutCount" label="超时次数" />
      <el-table-column :show-overflow-tooltip="true" width="90" prop="unArriveCount" label="未到场次数" />
      <el-table-column :show-overflow-tooltip="true" prop="sumTime" label="预计总服务时长" />
      <el-table-column :show-overflow-tooltip="true" prop="acSumTime" label="实际总服务时长" />
      <template v-for="a in tableTitle">
        <el-table-column :key="a" :label="a" align="center">
          <template v-for="col in tableName">
            <el-table-column
              :key="col.key"
              :label="col.name"
              align="center"
            >
              <template slot-scope="scope">
                <span v-if="col.key=='nook'">
                  {{ scope.row.unOkCount }}
                </span>
                <span v-if="col.key=='justok'">
                  {{ scope.row.justOkCount }}
                </span>
                <span v-if="col.key=='ok'">
                  {{ scope.row.okCount }}
                </span>
              </template>
            </el-table-column>
          </template>
        </el-table-column>
      </template>
      <template v-for="a in tableTitle1">
        <el-table-column :key="a" :label="a" align="center">
          <template v-for="col in tableName1">
            <el-table-column
              :key="col.key"
              :label="col.name"
              align="center"
            >
              <template slot-scope="scope">
                <span v-if="col.key=='la'">
                  {{ scope.row.levelACount }}
                </span>
                <span v-if="col.key=='lb'">
                  {{ scope.row.levelBCount }}
                </span>
                <span v-if="col.key=='lc'">
                  {{ scope.row.levelCCount }}
                </span>
              </template>
            </el-table-column>
          </template>
        </el-table-column>
      </template>
    </el-table>
    <!--分页组件-->
    <el-pagination
      :total="total"
      style="margin-top: 8px;"
      layout="total, prev, pager, next, sizes"
      @size-change="sizeChange"
      @current-change="pageChange"
    />
  </div>
</template>

<script>
import checkPermission from '@/utils/permission'
import initData from '@/mixins/initData'
import { parseTimeShort } from '@/utils/index'
import eHeader from './module/header'
import { download } from '@/api/data'
import { downloadFile } from '@/utils/index'
export default {
  components: { eHeader },
  mixins: [initData],
  data() {
    return {
      delLoading: false,
      supThis: this,
      tableName: [
        { name: '不满意', key: 'nook' },
        { name: '基本满意', key: 'justok' },
        { name: '满意', key: 'ok' }
      ],
      tableTitle: ['客户满意度'],
      tableName1: [
        { name: '初级工单', key: 'la' },
        { name: '中级工单', key: 'lb' },
        { name: '高级工单', key: 'lc' }
      ],
      tableTitle1: ['服务等级']
    }
  },
  created() {
    this.$nextTick(() => {
      this.init()
    })
  },
  methods: {
    parseTimeShort,
    checkPermission,
    download,
    downloadFile,
    beforeInit() {
      this.url = 'api/tServiceproviderInfo/evaluate'
      const sort = ''
      this.params = { page: this.page, size: this.size, sort: sort }
      const query = this.query
      if (query.refeName) {
        this.params['refeName'] = query.refeName
      }
      if (query.startTime) {
        this.params['startTime'] = query.startTime
      }
      if (query.endTime) {
        this.params['endTime'] = query.endTime
      }
      return true
    },
    exportExcel() {
      const url = 'api/tServiceproviderInfo/export'
      var params = {}
      const query = this.query
      if (query.refeName) {
        params['refeName'] = query.refeName
      }
      if (query.startTime) {
        params['startTime'] = query.startTime
      }
      if (query.endTime) {
        params['endTime'] = query.endTime
      }
      this.downloadLoading = true
      this.download(url, params).then(result => {
        this.downloadFile(result, '评价数据', 'xlsx')
        this.downloadLoading = false
      }).catch(() => {
        this.downloadLoading = false
      })
    }
  }
}
</script>

<style scoped>

</style>
